if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[GetLogItemsForProcess]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[GetLogItemsForProcess]
GO

/******************************************************************
* Name:			GetLogItemsForProcess
* Purpose:		Retrieves the LogItem for the given ProtocolProcessId
*					
*
* PARAMETERS
* Name    			Description					
* -------------  		----------------------------------
* @protocolProcessId		ProtocolProcessId for the LogItem
******************************************************************/

CREATE PROCEDURE [dbo].[GetLogItemsForProcess]
(
@protocolProcessId	int			
)
AS
BEGIN

	SET NOCOUNT ON

			Select	[Id],
				[QuestionnaireVersionId],
				[QuestionnaireAnswerId],
				[Type],
				[Category],
				[QuestionName],
				[Answer],
				[Description],
				[Completed]
				
					
			FROM LogItem LI INNER JOIN ProtocolProcess_LogItem_Map Map ON LI.Id = Map.LogItemId

			WHERE Map.[ProtocolProcessId] = @protocolProcessId  
	
END

